let arr = [2,4 ,7,3,1,6,5]

function insertSort(arr) {
    const len = arr.length
    let target
    for (let i = 0; i < len; i++) {
        target = arr[i]
        let j = i
        //遍历已经有序的值，找出target应在的位置
        while (arr[j - 1]> target) {
            arr[j] = arr[j-1]
            j--
        }
        arr[j] = target
    }
    return arr
}